<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:v="livcos.org/ns/view"
  exclude-result-prefixes="doc xs v">

	<xsl:template match="doc:chapter">
    <v:chapter id="{@id}">
			<v:title path="title">
				<xsl:apply-templates select="doc:title/node()"/>
			</v:title>
      <xsl:apply-templates select="* except doc:title"/>
    </v:chapter>
  </xsl:template>

  <xsl:template match="doc:paragraph">
  	<p id="{@id}" class="block inlineEdit"><xsl:apply-templates/></p>
  </xsl:template>

  <xsl:template match="doc:subject">
  	<div id="{@id}" class="block subject">
  		<v:style ref="{resolve-uri('styles.css')}"/>
  		<div class="title">
        <xsl:apply-templates select="doc:title/node()"/>
      </div>
      <div class="content">
        <xsl:apply-templates select="doc:content/node()"/>
      </div>
    </div>
  </xsl:template>

	<xsl:template match="doc:citation">
		<div id="{@id}" class="block citation">
			<v:style ref="{resolve-uri('styles.css')}"/>
			<div class="cit_content">"<xsl:apply-templates select="doc:content/node()"/>"</div>
			<div class="cit_ref">
				<a href="{@ref}"><xsl:apply-templates select="doc:title/node()"/></a>
				<xsl:text>, </xsl:text>
				<xsl:value-of select="format-dateTime(xs:dateTime(@time), '[D].[M].[Y]')"/>
			</div>
		</div>
	</xsl:template>
	
	<xsl:template match="doc:strong | doc:em | doc:q | doc:s | doc:u | doc:sup | doc:sub | doc:code | doc:br">
		<xsl:element name="{local-name(.)}">
			<xsl:apply-templates select="@*|node()"/>
		</xsl:element>
	</xsl:template>
	
</xsl:stylesheet>
